//继承！！  extends

class Animal{
    public String name;
    public int age;

    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }

    public void eat(){
        System.out.println(name+" 在吃饭");
    }
}

class Dog extends Animal{
//    public String name;
//    public int age;
    public float weigth;
    public Dog(String name,int age,float weigth){
        super(name,age);//显示的调用父类的构造函数，用来初始化此时子类继承过来的父类的属性
        this.weigth = weigth;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "weigth=" + weigth +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    //    public void eat(){
//        System.out.println(name+" 在吃饭");
//    }
    public void bark(){
        System.out.println(name+" 汪汪汪");

    }
}

class Cat extends Animal{
    public Cat(String name, int age) {
        super(name, age);
    }
//    public String name;
//    public int age;

//    public void eat(){
//        System.out.println(name+" 在吃饭");
//    }
    public void miaomiao(){
        System.out.println(name+" 喵喵喵");
    }
}


public class Test {

    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.age = 10;
        cat.name = "咪咪";
    }

    public static void main1(String[] args) {
        Dog dog = new Dog();
        dog.name = "狗子";
        dog.age = 10;
        dog.weigth = 30;
        dog.eat();
        dog.bark();
        System.out.println(dog);
    }
}
